package org.huyue.huyuexia.controller;

import lombok.extern.slf4j.Slf4j;
import org.huyue.huyuexia.pojo.User;
import org.huyue.huyuexia.service.UserService;
import org.huyue.huyuexia.util.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class LoginController {
    @Autowired
    private UserService  userService;
    @PostMapping("/login")
    public Result login(@RequestBody User  user)
    {
        return Result.success(userService.login(user));
    }

    @PostMapping("/register")
    public Result register(@RequestParam String username, @RequestParam String password)
    {
            userService.register(username, password);
            return Result.success();
    }
}
